package com.hdw.auth.service;

import com.hdw.common.vo.PaginationVO;
import org.springframework.stereotype.Service;
import com.hdw.auth.api.BaseAuthFuService;
import com.hdw.auth.mapper.BaseAuthFuMapper;
import com.hdw.auth.bean.model.BaseAuthFu;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * baseAuthFu服务实现类
 * Created by liujunlei on 2022/01/05.
 */
@Service
@Transactional
public class BaseAuthFuServiceImpl implements BaseAuthFuService{

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseAuthFuServiceImpl.class);

    @Autowired
    private BaseAuthFuMapper baseAuthFuMapper;

    @Override
    public int insert(BaseAuthFu baseAuthFu) {
        return baseAuthFuMapper.insert(baseAuthFu);
    }

    @Override
    public int insertSelective(BaseAuthFu baseAuthFu)  {
        return baseAuthFuMapper.insertSelective(baseAuthFu);
    }

    @Override
    public int deleteById(Long idFu)  {
        return baseAuthFuMapper.deleteByPrimaryKey(idFu);
    }

    @Override
    public int updateByIdSelective(BaseAuthFu baseAuthFu)  {

        return baseAuthFuMapper.updateByPrimaryKeySelective(baseAuthFu);
    }

    @Override
    public int updateById(BaseAuthFu baseAuthFu)  {
        return baseAuthFuMapper.updateByPrimaryKey(baseAuthFu);
    }

    @Override
    public BaseAuthFu getById(Long idFu)  {
        return baseAuthFuMapper.selectByPrimaryKey(idFu);
    }

    @Override
    public List<BaseAuthFu> findByModel(BaseAuthFu baseAuthFu)  {
        return baseAuthFuMapper.findByModel(baseAuthFu);
    }

    @Override
    public PaginationVO<BaseAuthFu> findPageByModel(BaseAuthFu baseAuthFu, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<BaseAuthFu> quesList = baseAuthFuMapper.findByModel(baseAuthFu);
        PageInfo<BaseAuthFu> pageInfo = new PageInfo<>(quesList);
        PaginationVO<BaseAuthFu> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }

    @Override
    public List<BaseAuthFu> findByIdUse(Long idUse) {
        return baseAuthFuMapper.findByIdUse(idUse);
    }
}
